package org.cqipc.edu.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @Description: Druid数据源配置
 * @ClassNmae: DruidConfig
 * @Author: HeYue
 * @DateTime: 2020-10-30 19:16
 **/
@Configuration
public class DruidConfig {

    /**
     * @Description: 注入druid数据源并设置不销毁
     * @Author: HeYue
     * @DateTime: 2020/10/30 19:17
     **/
    @Bean(destroyMethod = "close", initMethod = "init")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource getDataSource() {
        return new DruidDataSource();
    }

}
